<%--
  Created by IntelliJ IDEA.
  User: leixiaolong
  Date: 2018/11/22
  Time: 12:06 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户新增管理</title>
    <link rel="stylesheet" href="/static/css/rpt-condition.css" media="all" type="text/css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/layui/css/layui.css" media="all"
          type="text/css">

    <style>
        .layui-input-inline {
            min-width: 300px;
            max-width: 600px;
        }
    </style>
</head>
<body>
<div>
    <div class="layui-row layui-col-space10" style="margin: 10px; background-color: white">
        <div class="layui-container">
            <div class="layui-form" lay-filter="select-condition">
                <div class="layui-form-item layui-col-md12">
                    <label class="layui-form-label ">用户名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="user_name" name="userName" class="layui-input-inline dom-add-input"
                               lay-verify="required">
                    </div>
                </div>

                <div class="layui-form-item layui-col-md12" >
                    <label class="layui-form-label">所属机构：</label>
                    <div class="layui-input-inline">
                        <select id="organ_name" name="organCode" class="layui-form-select" lay-verify="required">
                            <option value="" selected>请选择</option>
                            <option value=1>机构1</option>
                            <option value=2>机构2</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item layui-col-md12">
                    <label class="layui-form-label">手机号码：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="phone" name="phone" class="layui-input-inline dom-add-input"
                               lay-verify="required|phone">
                    </div>
                </div>

                <div class="layui-form-item layui-col-md12" >
                    <label class="layui-form-label">用户角色：</label>
                    <div class="layui-input-inline">
                        <select id="user_role" name="roleCode" class="layui-form-select">
                            <option value=1 selected>角色1</option>
                            <option value=2>角色2</option>
                        </select>
                    </div>
                </div>
                <div class="layui-btn-group">
                    <button class="layui-btn layui-btn-normal layui-btn-warm" lay-submit="" data-type="confirm">提交</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>

<script language='javascript' src="${pageContext.request.contextPath}/plugins/layui/layui.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-select.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/component/form-date.js"></script>
<script language='javascript' src="${pageContext.request.contextPath}/static/js/utils/moment.js"></script>

<script>
    layui.use(["form", "jquery"], function () {
        var form = layui.form, $ = layui.jquery;

        initOrganSelect('organ_name', '/sys/getOrganList', null);
        initRoleSelection('user_role', '/sys/getRoleList', null);

        form.on('submit', function(data){
           var field = data.field;

            $.ajax({
                url: "/sys/addUserInfo",
                contentType: 'GET',
                async: false,
                data: field,
                success: function(data){
                    layer.msg("交易成功,"+JSON.stringify(data));
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);

                    parent.layui.table.reload("tab_instance", {});
                },
                error: function(data){
                    layer.msg("交易失败, message:"+data.rspMsg)
                }
            });
        });

    });
</script>
